<template>
	<view class="uni-container">
		<view class="uni-hello-text">
			<text class="hello-text">uni原生插件示例 SDK</text>
		</view>
		<view class="uni-panel" v-for="(item, index) in list" :key="item.id">
			<view class="uni-panel-h" :class="item.open ? 'uni-panel-h-on' : ''" @click="triggerCollapse(index)">
				<text class="uni-panel-text">{{item.name}}</text>
			</view>
			<view class="uni-panel-c" v-if="item.open">
				<view class="uni-navigate-item" v-for="(item2,key) in item.pages" :key="key" @click="goDetailPage(item2.url)">
					<text class="uni-navigate-text">{{item2.name ? item2.name : item2}}</text>
					<text class="uni-navigate-icon uni-icon">&#xe470;</text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	
	export default {
		data() {
			return {
				list: [
				{
					id: 'ext-module',
					name: 'Device Scan Sdk module',
					open: false,
					url: '/pages/sample/ext-module-device-scan'
				},
				{
					id: 'ext-module-rfid',
					name: 'RFID SDK module',
					open: false,
					url: '/pages/sample/ext-module-rfid'
				},{
					id: 'bluetooth-print',
					name: '便携式蓝牙打印机',
					open: false,
					url: '/pages/sample/bluetooth-print'
				},{
					id: 'bluetooth-sdk-print',
					name: '便携式蓝牙打印机(SDK)',
					open: false,
					url: '/pages/sample/bluetooth-sdk-print'
				},{
					id: 'ext-module-pda-pos-readid',
					name: 'PDA-POS身份证硬解模块',
					open: false,
					url: '/pages/sample/ext-module-pda-pos-readid'
				},{
					id: 'ext-module-nfc-readid',
					name: 'NFC读身份证（联网）',
					open: false,
					url: '/pages/sample/ext-module-nfc-readid'
				},
				{
					id: 'ext-module-pos',
					name: 'POS SDK',
					open: false,
					url: '/pages/index/index-pos'
				},
				{
					id: 'ext-module-rfid-c',
					name: 'RFID SDK compatible module',
					open: false,
					url: '/pages/sample/ext-module-rfidc'
				}
				],
				navigateFlag: false
			}
		},
		onLoad() {
					const systemInfo = uni.getSystemInfoSync();
			       var model = systemInfo.model;//型号
					console.log('model: ' + model);
					
					var Build = plus.android.importClass("android.os.Build");
					 var serial = Build.getSerial()
					console.log('serial' + serial);
					// uni.chooseImage({
					// 	count: 6, //默认9
					// 	sizeType: ['original', 'compressed'],  
					// 	sourceType: ['camera','album'], //拍照或相册选择
					// 	success: function (res) {
					// 		console.log(JSON.stringify(res.tempFilePaths));
					// 	}
					// });
 	
			// console.log('uni.getLocation()');
			// uni.getLocation({
			// 	// type: 'gcj02',
			// 	type: 'wgs84',
			// 	geocode: 'true',
			// 	success: function (res) {
			// 		console.log('经度：' + res.longitude);
			// 		console.log('纬度：' + res.latitude);

			// 		var imodal = this.modal;

			// 			// 创建地图坐标对象
			// 			var point = new plus.maps.Point(res.longitude, res.latitude);
			// 			//静态方法，反向地理编码
			// 			plus.maps.Map.reverseGeocode(point, {}, (event) => {
			// 				var address = event.address; // 转换后的地理位置
			// 				console.log('地址：' + JSON.stringify(event));
							
			// 				modal.toast({
			// 					message: '经度：' + event.coord.longitude+"\n"+'纬度：' + event.coord.latitude+"\n"+'地址：' + address,
			// 					duration: 1.5
			// 				});
							
							
			// 			}, function(e) {
			// 				console.log("失败回调", e);
			// 			});



					
			// 	}
			// });
		},
		onShow() {
		},
		onHide() {
		},
		methods: {
			triggerCollapse(e) {
							if (!this.list[e].pages) {
								this.goDetailPage(this.list[e].url);
								return;
							}
							for (var i = 0; i < this.list.length; ++i) {
								if (e === i) {
									this.list[i].open = !this.list[e].open;
								} else {
									this.list[i].open = false;
								}
							}
						},
						goDetailPage(e) {
							if (this.navigateFlag) {
								return;
							}
							this.navigateFlag = true;
							uni.navigateTo({
								url: e
							});
							setTimeout(() => {
								this.navigateFlag = false;
							}, 200)
							return false;
						}
			
		}
	}
</script>

<style>
</style>
